﻿using System;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace FindProxy
{
    public partial class frmIpConvert : Form
    {
        public frmIpConvert()
        {
            InitializeComponent();
        }
        Regex rex;

        private void button1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = openFileDialog1.FileName;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = openFileDialog1.FileName;
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            rex = new Regex(@"(\d+\.\d+\.\d+\.\d+:\d+)");
            string data;
            using (StreamReader sr = new StreamReader(textBox1.Text))
            {
                data = sr.ReadToEnd();
            }

            MatchCollection mac = rex.Matches(data);

            using (StreamWriter sw = new StreamWriter(textBox1.Text))
            {
                foreach (Match m in mac)
                {
                    sw.WriteLine(m.ToString());
                }
            }
            MessageBox.Show("OK");

        }
    }
}
